import request from 'utils/request'

/**
 * 获取文章列表页面
 * @returns 
 */
export const getArticles = (altquery) => {
    return request({
        method:'get',
        url:'/mp/articles',
        params:altquery
    })
}

/**
 * 删除文章
 * @param {Number} id 
 * @returns 
 */
export const deleteArticle = (id) => {
    return request({
        method:'delete',
        url:`/mp/articles/${id}`
    })
}

/**
 * // 发布文章
 * @param {*} data // 文章数据
 * @param {Boolean} draft // 是否是草稿
 * @returns 
 */
export const addArticle = (data,draft) => {
    return request({
        method:'post',
        url:'/mp/articles/?draft='+draft,
        headers:{'Content-Type':'application/json'},
        data
    })
}

/**
 * // 修改文章
 * @param {*} data // 文章数据
 * @param {Boolean} draft // 是否是草稿
 * @param {*} id // 修改ID
 * @returns 
 */
export const editArticle = (data,draft,id) => {
    return request({
        method:'put',
        url:'/mp/articles/'+id+'/?draft='+draft,
        headers:{'Content-Type':'application/json'},
        data
    })
} 

/**
 * // 获取文章详情
 * @param {*} id 文章ID
 * @returns 
 */
export const getArticleContent = (id) => {
    return request({
        method:'get',
        url:'/mp/articles/'+id,
    })
}